$(function () {
    vm.subSellerList();
    vm.querySellerInfo();
})

var vm = new Vue({
    el:'#rrapp',
    data:{
        /* 子公司分页参数 */
        subSellerPage:{
            currPage:1, // 当前页
            pageSize:8, // 分页数
            totalCount:0, // 总条数
            tableData:[], //数据列
        },
        sellerInfoVo:{
            sellerName: '',
            url: 'https://ziyunoss.oss-cn-hangzhou.aliyuncs.com/erpTest/test/1538299323397.jpg',
            doorheadName: '',
            name:'',
            sellerMobile:'',
            address: '',
            waitPayNum: 10,
            payedNum: 12,
            sendNum: 23,
            finishNum: 36,
            waitWithdraw: 8600,
            withdrawing: 6923,
            alreadyWithdraw: 98745,
            goodsNum: 100,
            saleGoodsNum: 62,
            offGoodsNum: 38,
        },
        chartData: {
            columns: ['日期', '销量', ],
            rows: [
                { '日期': '1/1', '销量': 1393},
                { '日期': '1/2', '销量': 3530},
                { '日期': '1/3', '销量': 2923},
                { '日期': '1/4', '销量': 1723},
                { '日期': '1/5', '销量': 3792},
                { '日期': '1/6', '销量': 4593}
            ]
        },
        sellChartSettings: {
            axisSite: { right: ['订单数','客户数'] },
            yAxisType: ['KMB', ''],
            yAxisName: ['金额', '数量']
        },
        sellChartData: {
            columns: ['日期', '营业额', '订单数', '客户数'],
            rows: [
                { '日期': '1/1', '营业额': 1393, '订单数': 5, '客户数': 4 },
                { '日期': '1/2', '营业额': 3530, '订单数': 7, '客户数': 3 },
                { '日期': '1/3', '营业额': 2923, '订单数': 3, '客户数': 9 },
                { '日期': '1/4', '营业额': 1723, '订单数': 8, '客户数': 5 },
                { '日期': '1/5', '营业额': 3792, '订单数': 7, '客户数': 5 },
                { '日期': '1/6', '营业额': 4593, '订单数': 4, '客户数': 7 }
            ]
        },
        customChartData: {
            columns: ['类型', '客户数'],
            rows: [
                { '类型': '新客户', '客户数': 100 },
                { '类型': '老客户', '客户数': 200 }
            ]
        }
    },
    methods: {
        querySellerInfo: function () {
            $.ajax({
                type: "GET",
                url: baseURL + "supp/sellerinfo/querySellerInfo",
                contentType: "application/json",
                data: null,
                success: function(r){
                    console.log(r);
                    vm.sellerInfoVo = r.sellerInfoVo;
                    jQuery('#qrcode').qrcode({
                        width: 200,
                        height: 200,
                        text: 'https://www.11ziyun.com/wap/merchant-info/'+vm.sellerInfoVo.sellerId,
                    });
                }
            });
        },
        subSellerList: function () {
            var queryData = {
                "limit":vm.subSellerPage.pageSize,
                "page":vm.subSellerPage.currPage
            }
            $.ajax({
                type: "GET",
                url: baseURL + "supp/sellerinfo/querySubSeller",
                contentType: "application/json",
                data: queryData,
                success: function(r){
                    vm.subSellerPage.tableData = r.page.list
                    vm.subSellerPage.totalCount = r.page.totalCount
                }
            });
        },
        /* 分页数改变 */
        handleSizeChange: function(val) {
            vm.subSellerPage.pageSize = val;
            vm.subSellerList();
        },
        /* 分页当前页改变改变 */
        handleCurrentChange: function(val) {
            vm.subSellerPage.currPage = val
            vm.subSellerList();
        },
        createSubSeller: function () {
            window.location.href = "/modules/supp/subsellerinfo.html";
        }
    }
});